﻿function matchTableCheckBox(headName, postfixChildName,showException) {

    try
    {
        $('input[id$=' + headName + ']').click(function () {
            var numOfCheckBox = $('input[id$=' + postfixChildName + ']').length;
            var cInstance = $(this);
            $.map($('input[id$=' + postfixChildName + ']'), function (n, i) {
                $(n).attr('checked', $(cInstance).attr('checked'));
            })
        });

        $('input[id$=' + postfixChildName + ']').click(function () {
            var numOfCheckBox = $('input[id$=' + postfixChildName + ']').length;
            if (!$(this).attr('checked')) {
                $('input[id$=' + headName + ']').attr('checked', false);
            }
            else if (numOfCheckBox == $('input[id$=' + postfixChildName + ']:checked').length) {
                $('input[id$=' + headName + ']').attr('checked', true);
            }
        });
    }
    catch(e)
    {
        if (showException) {
            throw e;
        }
    }

}

function queryString(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

function hideDeleteColumn() {
    if (queryString('del') != '1') {
        $('.col_delete').hide();
    }
    
}

function hilightInactive() {
    
    var cObj = $('.f_status').toArray();
    $.map(cObj, function(n) {
    if ($(n).text().trim() == 'ไม่ใช้งาน' || $(n).text().trim() == 'ไม่มีสิทธิ์เข้าใช้งาน') {
            $(n).parent().find('td').css('background-color', '#C0C0C0');
        }
    })
    

}